<?php
/**
 * +------ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER * ---------+
 * +----------------------------------------------------------------------------+
 * | PHPKiisf - Keep It in Simple Framework										|
 * | Version 1.0																|
 * | Copyright (C) <2013>  Mario Cezzare <mcezzare@gmail.com>					|
 * | Blog: http://mcezzare.blogspot.com.br										|
 * |																			|
 * | This program is part of PHPKiisf, and is free software: you can			|
 * | redistribute it and/or modify it under the terms of the GNU 				|
 * | General Public License as published by										|
 * | the Free Software Foundation, either version 3 of the License, or			|
 * | (at your option) any later version.										|
 * |																			|
 * | This program is distributed in the hope that it will be useful,			|
 * | but WITHOUT ANY WARRANTY; without even the implied warranty of				|
 * | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the				|
 * | GNU General Public License for more details.								|
 * | You should have received a copy of the GNU General Public License			|
 * | along with this program.  If not, see <http://www.gnu.org/licenses/>.		|
 * +----------------------------------------------------------------------------+
 * | Author : <Mario Cezzare Angelicola Chiodi> <mcezzare@gmail.com>			|
 * +----------------------------------------------------------------------------+
 * | Contributors																|
 * |																			|
 * +----------------------------------------------------------------------------+
 *
 */
/**
 * This file is the default model for start pages, open it and save as...
 *
 * @package Templates
 * @access public
 * @since 2013-03-08
 * @author Mario Cezzare <mcezzare@gmail.com>
 */
?>
<?php
require_once sprintf( "%s/%s%s" , base_template::$public_dir , 'header' , INCLUDE_EXTENSION );
?>

<?php
require_once ( "syntax_highlighter_headers.inc.php" );
require_once sprintf( "%s/%s%s" , base_template::$public_dir , 'navbar' , INCLUDE_EXTENSION );


//just to minify
$global_params	 = base_template::$global_params;
/**
 * Verifiy if this page is running on test mode
 */
$test_mode		 = false;
if ( is_array( $global_params ) ) {
		if ( in_array( "test" , $global_params[ 0 ] ) ) {
				$test_mode = true;
		}
}
//uncomment for debug
//echo __FILE__ . "<br>" ;
//print_r( dispatcher::$_active_route ) ;
//print_r( $global_params ) ;
?>

<div class="container">
		<div class="hero-unit">
				<h1>
						<?= base_template::$section_name; ?>
				</h1>
				<p>Using this Framework<br />
						This page use the library <a href="http://alexgorbatchev.com/SyntaxHighlighter">SyntaxHighlighter</a> <span id="version">3.0.83</span> for	display	code. </p>

		</div>
		<div class="accordion-heading">
				<ul class="nav nav-tabs nav-stacked">
						<li><a href="#new_section">1 - Creating a new Section or Route</a></li>
						<li><a href="#database">2 - Configuring Database Access</a></li>
						<li><a href="#mvc_gen">3 - Generating Php Code for Bussiness Objects</a></li>
				</ul>

				<p>&nbsp;</p>
		</div>
		<div class="container">
				<h3 class="text-info"> <a name="new_section" id="new_section"></a>1. How to create a new route, or new section</h3>
				<br />Lets see this page for example.
				<h4>1.1 - Add the desired route on root/index.php. </h4>
				<pre class="brush: php">&lt;?<br />/**<br /> * Examples Section<br /> */<br />$dispatcher-&gt;add_route( array( &quot;GET&quot; , &quot;/?examples/&quot; , &quot;example_controller:display_index&quot; ) );<br />$dispatcher-&gt;add_route( array( &quot;GET&quot; , &quot;/?examples/boilerplate/&quot; , &quot;example_controller:display_boilerplate_examples&quot; ) );<br />$dispatcher-&gt;add_route( array( &quot;GET&quot; , &quot;/?examples/php/&quot; , &quot;example_controller:display_php_examples&quot; ) );
?&gt;</pre>
				<h4>1.2 - Optional : If needed create a new entry in lib/phpkiisf.ini in TEMPLATES section, and create the respective  template extending the default_template 	(open example_template.class.php and save as.. *_template.class.php)</h4>
				<pre class="brush: php">EXAMPLES_HOME=./app/templates/example_template.class.php</pre>
				Look the file: /app/templates/example_template.class.php <br />
				<pre class="brush: php">
						<?= htmlspecialchars( file_get_contents( TEMPLATES_DIR . "example_template.class.php" ) ); ?>
				</pre>
				<h4> Hit http://yourserver/examples, you'll get a screen like this : </h4>
				<br>
				Hello from : default_controller
				<pre style="border:solid 1px #EA9C5C;  padding:3px; color:#000000; background-color:#ededed ">array (
  'dispatcher_msg' => 'called from line 207 by /var/sites/novoencanto.lpanic.intra/lib/dispatcher.class.php',
  'url_param' =>
  array (
  ),
  'post' =>
  array (
  ),
  'query_string' => '',
  'active_route' => 'examples',
  'controller' => 'example_controller',
  'method' => 'display_index',
)
				</pre>
				caused by default_controller
				<pre class="brush: php">
&lt;?
//.....more
/**
 * Include the default template
 *
 * @param Array $options , some useful params to control
 * the default template behavior
 * @return boolean
 */
public static function display_index( $options = array( ) ) {
        display_message( sprintf( "Hello from : %s <br>" , __CLASS__ ) );

        if ( count( $options ) ) {
                if ( in_array( "ERR" , $options ) ) {
                        utils::show_object( $options );
                }
                else {
                        utils::show_object( $options );
                }
        }
        return true;
}?&gt;
				</pre>
				<hr size="1" width="100%" />
				It happens because the controller is using the extended method from default_controller, override this method, or create one.<br />
				<h4>1.3 - Create the static method on specified controller, or create a new controller extending the default_controller	(open example_controller.class.php and save as.. *_controller.class.php)</h4>
				<pre class="brush: php">
						<?= htmlspecialchars( file_get_contents( CONTROLLER_DIR . "example_controller.class.php" ) ); ?>
				</pre>
				<h4>1.4 - Test the urls.On Templates before the html stuff, the is some lines commented. Uncomment them to see what file is beeig called.</h4>
				<pre class="brush: php">
&lt;?
//uncomment for debug
//echo __FILE__  ;
//print_r( dispatcher::$_active_route ) ;
//print_pre( $global_params ) ;
?&gt;</pre>
				<h4> 1.5 - If you want to see all classes are beeing loaded in run time, inform on query string ?debug=true. It's configured on file /lib/init.php<br />
						It must be disabled on production environments and used only to solve problems<br />
				</h4>
				<pre class="brush: php">
&lt;? $debug = false;<br />if ( $context == &quot;deploy&quot; ) {
		if ( isset( $_GET[ &quot;debug&quot; ] ) ) {
        				$debug = $_GET[ &quot;debug&quot; ] == true ? true : false;
       }
}
?&gt;</pre>
		</div>
		<div>
				<h3 class="text-info"> <a name="database" id="database"></a>2. Configuring database access</h3>
                <h4>2.1 Fill the file lib/phpkiisf.ini according to your database type and settings</h4>
				<?
				gui_controller::create_button(
						array(
								"class" => "btn btn-primary btn-success" ,
								"href" => "/config/db" ,
								"value" => "Test Db Access" ,
						)
				);
				?>
                <p>desc</p>

		</div>
		<div>
				<h3 class="text-info"> <a name="mvc_gen" id="mvc_gen"></a>3. MVC Objects</h3>
				<h4>title</h4>
				<p>desc</p>
		</div>

		<div>
				<h3 class="text-info"> <a name="a_name" id="a_name"></a>4. Item</h3>
				<h4>title</h4>
				<p>desc</p>
		</div>

		<div class="span12">
				<hr>
				<footer>
						<p> &copy; <a href="<?= FMW_URL_ABOUT; ?>" target="_blank">PHPKissf 2013</a> </p>
				</footer>
		</div>
</div>
</div>
<!-- /container -->
<?
require_once sprintf( "%s/%s%s" , base_template::$public_dir , 'footer' , INCLUDE_EXTENSION );
?>
